﻿using Red.CommUtils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Red.EngineData.Tests
{
    internal class ChannelMock : IChannel
    {
        public int Called_IsOpen = 0;
        public int Called_Send = 0;
        public int Called_SendAck = 0;
        public int Called_RegisterListener = 0;
        public int Called_UnregisterListener = 0;

        public string Name
        {
            get { return "ChannelMocek"; }
        }

        public void ClearCallCounters()
        {
            Called_IsOpen = 0;
            Called_Send = 0;
            Called_SendAck = 0;
            Called_RegisterListener = 0;
            Called_UnregisterListener = 0;
        }

        public bool IsOpen()
        {
            Called_IsOpen++;
            return true;
        }

        public void Send(comm.Message message)
        {
            Called_Send++;
        }

        public void SendAck(comm.Message message, MessageResponseHandler handler)
        {
            Called_SendAck++;
        }

        public comm.Message SendAndWait(comm.Message message, int timeoutInMS)
        {
            throw new Exception("We don't expect to use SendAndWait.");
        }

        public void RegisterListener(ChannelIncomingMessageEventHandler listener)
        {
            Called_RegisterListener++;
        }

        public void UnregisterListener(ChannelIncomingMessageEventHandler listener)
        {
            Called_UnregisterListener++;
        }

        public Task<bool> TryReconnect( int timeout )
        {
            throw new NotImplementedException();
        }

        public void ShutDown()
        {
            throw new NotImplementedException();
        }
        public ulong TotalBytesReceived
        {
            get { throw new NotImplementedException(); }
        }

        public ulong TotalBytesSent
        {
            get { throw new NotImplementedException(); }
        }
    }
}
